package com.hue.netty.day01.three;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

public class ServerChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast("decoder",new StringDecoder()); //添加解码器
        pipeline.addLast("encoder",new StringEncoder()); //添加编码器
        pipeline.addLast(new ServerHandler()); //添加自定义处理器
    }
}
